var /**
	 * 仿真流程管理
	 */
TeachFlow = cc.Class.extend({
	step:0,
	flow:null,
	main:null,
	over_flag: false,
	curSprite:null,
	ctor: function(){
		this.init();
	},
	setMain:function(main){
		this.main=main;
	},
	init: function(){
		for(var i in teach_flow){
			teach_flow[i].finish = false;
			teach_flow[i].cur = false;
			if(teach_flow[i].action == null){
				teach_flow[i].action = ACTION_NONE;
			}
		}
	},
	start:/**
			 * 开始流程
			 */
	function(){
		this.over_flag = false;
		this.step = 0;
		
		/* 新标准，开始的时候，执行下一步 */
		this.next();
	},
	over:/**
			 * 流程结束，计算分数，跳转到结束场景，
			 */
	function(){
		this.over_flag = true;
		this.flow = over;
		gg.lastStep = this.step;
		this.main.over();
	},
	checkTag:/**
				 * 检查是否当前步骤
				 * 
				 * @deprecated 使用新Angel类，不再判断是否当前步骤
				 * @param tag
				 * @returns {Boolean}
				 */
	function(tag){
		var cur_flow = teach_flow[this.step - 1];
		if(cur_flow.tag == tag){
			return true;
		} else {
			return false;
		}
	},
	prev:/**
			 * 回退一定步数
			 * 
			 * @deprecated 需结合具体实现，，暂时不再启动
			 * @param count
			 *            步数
			 */
	function(count){
		if(this.curSprite!=null){
			this.curSprite = null;
		}
		if(this.flow!=null){
			this.flow.cur = false;
		}
		this.step = this.step - count;
		this.flow = teach_flow[this.step - 1];
		this.refresh();
		gg.score -= 11;
	},
	next:/**
			 * 执行下一步操作， 定位当前任务
			 */
	function(){
		if(this.over_flag){
			return;
		}
		if(this.curSprite!=null){
			this.curSprite.setEnable(false)
			this.curSprite = null;
		}
		if(this.flow!=null){
			this.flow.cur = false;
			// 标记任务已完成
			this.flow.finish = true;
		}
		this.flow = teach_flow[this.step++];
		if(this.flow.finish){
			// 如果任务已完成，跳过当前步骤
			this.next();
		}
		this.refresh();
	},
	refresh:/**
			 * 刷新当前任务状态，设置闪现，点击等状态
			 */
	function(){
		// 刷新提示
		this.flow.cur = true;
		if(this.flow.tip != null){
			ll.tip.tip.doTip(this.flow.tip);
		}
		if(this.flow.flash != null){
			ll.tip.flash.doFlash(this.flow.flash);
		}
		if(this.step > teach_flow.length - 1){
			this.over();
		}
		this.initCurSprite();
		if(this.curSprite!=null){
			this.location();
			this.curSprite.setEnable(true);
		}
	},
	location:/**
	 * 定位箭头
	 */
		function(){
		var tag = gg.flow.flow.tag;
		if(tag instanceof Array){
			if(TAG_LIB_MIN < tag[1]){
				if(ll.run.lib.isOpen()){
					ll.tip.arr.pos(this.curSprite);
				}else{
					//ll.tip.arr.setPosition(gg.width-45,455);
					ll.tip.arr.pos(ll.tool.getChildByTag(TAG_BUTTON_LIB));
				}
			}else{
				ll.tip.arr.pos(this.curSprite);
			}
		}
		else {
			ll.tip.arr.pos(this.curSprite);
		}		
	},
	getStep:/**
			 * 获取当前步数
			 * 
			 * @returns {Number}
			 */
	function(){
		return this.step;
	},
	initCurSprite:/**
					 * 遍历获取当前任务的操作对象
					 */
	function(){
		var tag = this.flow.tag;
		if(tag == null || tag == undefined){
			return;
		}
		var root = ll.run;
		var sprite = null;
		if(tag == TAG_BUTTON_LIB){
			sprite = ll.tool.getChildByTag(tag);
		} else if(tag instanceof Array){
			// 数组
			for (var i in tag) {
				root = root.getChildByTag(tag[i]);
			}
			sprite = root;
		} else {
			// 单个tag
			var sprite = root.getChildByTag(tag);
		}
		if(sprite != null){
			this.curSprite = sprite;
			return;
		}
	}
});

// 任务流
teach_flow = [
//

	{tip:"打开物品库",tag:TAG_BUTTON_LIB},
	{tip:"取出蒸馏水瓶",tag:[TAG_LIB,TAG_LIB_KETTLE]},
	{tip:"取出刻度为250ml量筒",tag:[TAG_LIB,TAG_LIB_CYLINDER1]},
//////////	
	{tip:"取出烧杯",tag:[TAG_LIB,TAG_LIB_BEAKER]},
	{tip:"使用刻度为250ml量筒量取200ml蒸馏水",tag:[TAG_KETTLE_NODE,TAG_KETTLE],action:K1},
	{tip:"将量取的蒸馏水倒入烧杯中",tag:[TAG_CYLINDER1_NODE,TAG_CYLINDER1]},
//	
	{tip:"取出浓硫酸",tag:[TAG_LIB,TAG_LIB_DROP],action:ACTION_DO1},
	{tip:"取出刻度为50ml量筒",tag:[TAG_LIB,TAG_LIB_CYLINDER]},
	{tip:"取出浓硫酸的玻璃瓶塞,注意瓶塞朝上",tag:[TAG_HHCL_NODE,TAG_HCORK]},
	{tip:"使用刻度为50ml的量筒量取27ml浓硫酸",tag:[TAG_HHCL_NODE,TAG_HHCL]},
	{tip:"取出玻璃棒",tag:[TAG_LIB,TAG_LIB_ROD],action:ACTION_DO1},
	{tip:"把量取的浓硫酸沿烧杯壁慢慢注入盛有200ml水的烧杯中，并不断用玻璃棒搅拌，使产生的热量迅速扩散",tag:[TAG_CYLINDER_NODE,TAG_CYLINDER]},

	{tip:"取出容量瓶",tag:[TAG_LIB,TAG_LIB_VOLUMETRIC]},
	{tip:"取出容量瓶瓶塞,注意瓶塞底部位置不要直接接触到桌面",tag:[TAG_VOLUMETRIC_NODE,TAG_LID6],action:K6},
	{tip:"容量瓶中注入烧杯中的溶液并用玻璃棒引流",tag:[TAG_BEAKER_NODE,TAG_BEAKER],action:ACTION_DO1},
	{tip:"使用蒸馏水清洗烧杯内壁与玻璃棒,",tag:[TAG_KETTLE_NODE,TAG_KETTLE],action:K2},
	{tip:"将清洗液注入容量瓶中并用玻璃棒引流",tag:[TAG_BEAKER_NODE,TAG_BEAKER],action:ACTION_DO2},
	{tip:"使用蒸馏水清洗烧杯内壁与玻璃棒",tag:[TAG_KETTLE_NODE,TAG_KETTLE],action:K2},
	{tip:"将清洗液注入容量瓶中并用玻璃棒引流",tag:[TAG_BEAKER_NODE,TAG_BEAKER],action:ACTION_DO3},
	{tip:"再次使用蒸馏水清洗烧杯内壁与玻璃棒",tag:[TAG_KETTLE_NODE,TAG_KETTLE],action:K2},
	{tip:"将清洗液注入容量瓶中并用玻璃棒引流",tag:[TAG_BEAKER_NODE,TAG_BEAKER],action:ACTION_DO4},

	{tip:"盖上容量瓶瓶塞", tag:[TAG_VOLUMETRIC_NODE,TAG_LID6],action:K2},
	{tip:"轻轻摇动容量瓶，使溶液混合均匀", tag:[TAG_VOLUMETRIC_NODE,TAG_VOLUMETRIC],action:ACTION_DO1},
	{tip:"取出容量瓶瓶塞",tag:[TAG_VOLUMETRIC_NODE,TAG_LID6],action:K6},
	{tip:"继续向容量瓶中加入蒸馏水，直到液面在500ml刻度线以下1-2厘米",tag:[TAG_KETTLE_NODE,TAG_KETTLE],action:K3},

	{tip:"取出装有蒸馏水溶液的胶头滴管",tag:[TAG_LIB,TAG_LIB_DROP],action:ACTION_DO2},
	{tip:"用胶头滴管逐滴加水，使溶液凹面恰好与刻度线相切",tag:[TAG_LIB_BURETTE,TAG_BURETTE],action:ACTION_DO2},
	{tip:"盖好容量瓶瓶塞", tag:[TAG_VOLUMETRIC_NODE,TAG_LID6],action:K3},
	{tip:"反复颠倒摇匀", tag:[TAG_VOLUMETRIC_NODE,TAG_VOLUMETRIC],action:ACTION_DO2},
	{tip:"取出试剂瓶",tag:[TAG_LIB,TAG_LIB_DROP],action:ACTION_DO3},
	{tip:"取出试剂瓶瓶塞，注意瓶塞朝上",tag:[TAG_HBOTTLE_NODE,TAG_HCORK1],action:ACTION_DO3},
	{tip:"取出容量瓶瓶塞",tag:[TAG_VOLUMETRIC_NODE,TAG_LID6],action:K7},
	{tip:"取出玻璃棒",tag:[TAG_LIB,TAG_LIB_ROD],action:ACTION_DO2},
	{tip:"将容量瓶溶液注入试剂瓶中并用玻璃棒引流", tag:[TAG_VOLUMETRIC_NODE,TAG_VOLUMETRIC],action:ACTION_DO3},
	{tip:"盖好试剂瓶瓶塞",tag:[TAG_HBOTTLE_NODE,TAG_HCORK1],action:ACTION_DO4},



	{tip:"恭喜过关",over:true}
];
over = {tip:"恭喜过关"};



